package com.kmproject.haifu.mvp.ui.adapter;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.http.imageloader.glide.ImageConfigImpl;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.widget.alertview.AlertView;
import com.jess.arms.widget.alertview.AlertViewOnItemClickListener;
import com.kmproject.haifu.R;
import com.kmproject.haifu.mvp.model.entity.beans.MemberCenterUserInfoBean;
import com.kmproject.haifu.mvp.model.entity.beans.MyStoryBean;
import com.kmproject.haifu.mvp.presenter.MyStorySelectNewPresenter;
import com.kmproject.haifu.mvp.ui.activity.MyStoreActivity;

import java.util.List;

public class PublicHouseXZDPItemAdapter extends BaseQuickAdapter<MyStoryBean.ResultBean, BaseViewHolder> {
    ImageLoader glideImage;
    MemberCenterUserInfoBean mmemberCenterUserInfoBean;
    boolean isSecondHande = false;

    public PublicHouseXZDPItemAdapter(MemberCenterUserInfoBean memberCenterUserInfoBean, @Nullable List<MyStoryBean.ResultBean> data) {
        super(R.layout.mystore_selectstory_item_item, data);
        mmemberCenterUserInfoBean = memberCenterUserInfoBean;

    }

    public void setSecondHande(boolean secondHande) {
        isSecondHande = secondHande;
    }

    @Override
    protected void convert(BaseViewHolder helper, MyStoryBean.ResultBean item) {
        helper.<LinearLayout>getView(R.id.selectstory_item_item_check_lay).setVisibility(View.GONE);
        if (glideImage == null) {
            glideImage = ArmsUtils.obtainAppComponentFromContext(mContext).imageLoader();
        }
        helper.<TextView>getView(R.id.item_item_dpName_txt).setText(item.getStoreName());
        glideImage.loadImage(mContext, ImageConfigImpl.builder().url(item.getStoreLogo()).imageRadius(5)
                .imageView(helper.<ImageView>getView(R.id.selectstory_item_item_dpHead_img))
                .build());
            //已关闭和审核过的 ，2-审核通过
            helper.<TextView>getView(R.id.item_item_onLine_txt).setVisibility(View.VISIBLE);
            helper.<TextView>getView(R.id.item_item_dpJb_txt).setText(item.getStoreRankName());
            glideImage.loadImage(mContext, ImageConfigImpl.builder().url(mmemberCenterUserInfoBean.getMemberLevel().getHeadImage()).imageRadius(5)
                    .imageView(helper.<ImageView>getView(R.id.item_item_hydj_img))
                    .build());
            helper.<TextView>getView(R.id.item_item_dplx_txt).setVisibility(View.GONE);
            if (item.getPublishInfoType() == 0) {
                helper.<TextView>getView(R.id.item_item_onLine_txt).setText(ArmsUtils.getString(mContext, R.string.mystory_zxfy) + " " + item.getOnlineCount());
            } else if (item.getPublishInfoType() == 1) {
                helper.<TextView>getView(R.id.item_item_onLine_txt).setText(ArmsUtils.getString(mContext, R.string.mystory_zxwp) + " " + item.getSecondHandCount());
            } else {
                helper.<TextView>getView(R.id.item_item_onLine_txt).setText(ArmsUtils.getString(mContext, R.string.mystory_zxpw) + " " + item.getOnlineCount());
            }
            if (item.getIsShow() == 0) {
                //已关闭
                helper.<TextView>getView(R.id.item_item_dpStatus_txt).setText(ArmsUtils.getString(mContext, R.string.mystory_ygb));
                helper.<TextView>getView(R.id.item_item_dpStatus_txt).setTextColor(ArmsUtils.getColor(mContext, R.color.color_999999));
//              helper.<TextView>getView(R.id.item_item_del_txt).setVisibility(View.VISIBLE);

            } else if (item.getReviewStatus() == 2) {
                helper.<TextView>getView(R.id.item_item_dpStatus_txt).setText(ArmsUtils.getString(mContext, R.string.mystory_jyz));
                helper.<TextView>getView(R.id.item_item_dpStatus_txt).setTextColor(ArmsUtils.getColor(mContext, R.color.color_3cb035));
            }

//       else {
//           //0-未审核，1-审核中,3-审核未过
//       }
        if (helper.getPosition() == getData().size() - 1) {
            helper.getView(R.id.item_item_view).setVisibility(View.GONE);
        }


    }
}
